﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Twodi.Aspect.Implemented;
using Microsoft.Xna.Framework;
using Twodi.Aspect.Interfaces;

namespace Twodi.Aspect.Implemented
{
    /// <summary>
    /// Define uma transformação padrão de componente que possui Posição, Tamanho, Escala e Rotação.
    /// </summary>
    public class NormalTransformationAspect : AbstractTransformationAspect<INormalTransformationAspect>
    {
        /// <summary>
        /// Construtor padrão.
        /// </summary>
        /// <param name="component">Componente cujo o aspecto é dependente.</param>
        public NormalTransformationAspect(INormalTransformationAspect component)
            : base(component)
        {

        }

        /// <summary>
        /// Matrix de transformação do componente.
        /// </summary>
        public override Matrix Transformation
        {
            get
            {
                return Matrix.CreateTranslation(-this.Component.RotationProperties.Origin.X, -this.Component.RotationProperties.Origin.Y, 0) *
                            Matrix.CreateRotationZ(this.Component.RotationProperties.Angle) *
                            Matrix.CreateScale(this.Component.ScaleProperties.Scale) *
                            Matrix.CreateTranslation(this.Component.PositionProperties.Position.X, this.Component.PositionProperties.Position.Y, 0);
            }
        }
    }
}
